
bool run_server()
{
	int portno = 6565;
	int new_sockfd ;
	int i = 0;
	pthread_t thread[100];
	//creates new socket IPv4 TCP and stores descriptor in sockfd
	int sockfd = socket(AF_INET, SOCK_STREAM, 0);
	if (sockfd < 0) {
		std::cerr << "ERROR opening socket" << std::endl;
		return 1;
	}
	//Creates and initializes sock_addr_in structure.
	sockaddr_in serv_addr;
	memset(&serv_addr, 0, sizeof(sockaddr_in));
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_addr.s_addr = INADDR_ANY;
	// htons converts 16bit integer to network byte order.
	serv_addr.sin_port = htons(portno);
	if(bind(sockfd, (sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
		std::cerr << "Can't bind socket: errno " << errno << std::endl;
		return 1;
	}
	// Start listening for incoming connections, 5 is size of backlog queue.
	listen(sockfd, 10);
	sockaddr_in cli_addr;
	socklen_t cli_len = sizeof(cli_addr);
	while(newsockfd = accept(sockfd, (sockaddr*)&cli_addr, &cli_len)){
		char* host_name = inet_ntoa(cli_addr.sin_addr);
		cli.newsockfd = newsockfd;
		add_user();
	}
	return true; 
}
